package com.ruoyi.supplier.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supplier.domain.TbStoreShelfDetail;
import com.ruoyi.supplier.service.ITbStoreShelfDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存盘点明细Controller
 * 
 * @author ruoyi
 * @date 2021-03-08
 */
@RestController
@RequestMapping("/supplier/storeShelfDetail")
public class TbStoreShelfDetailController extends BaseController
{
    @Autowired
    private ITbStoreShelfDetailService tbStoreShelfDetailService;

    /**
     * 查询库存盘点明细列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeShelfDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbStoreShelfDetail tbStoreShelfDetail)
    {
        startPage();
        List<TbStoreShelfDetail> list = tbStoreShelfDetailService.selectTbStoreShelfDetailList(tbStoreShelfDetail);
        return getDataTable(list);
    }

    /**
     * 导出库存盘点明细列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeShelfDetail:export')")
    @Log(title = "库存盘点明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbStoreShelfDetail tbStoreShelfDetail)
    {
        List<TbStoreShelfDetail> list = tbStoreShelfDetailService.selectTbStoreShelfDetailList(tbStoreShelfDetail);
        ExcelUtil<TbStoreShelfDetail> util = new ExcelUtil<TbStoreShelfDetail>(TbStoreShelfDetail.class);
        return util.exportExcel(list, "storeShelfDetail");
    }

    /**
     * 获取库存盘点明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeShelfDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbStoreShelfDetailService.selectTbStoreShelfDetailById(id));
    }

    /**
     * 新增库存盘点明细
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeShelfDetail:add')")
    @Log(title = "库存盘点明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbStoreShelfDetail tbStoreShelfDetail)
    {
        return toAjax(tbStoreShelfDetailService.insertTbStoreShelfDetail(tbStoreShelfDetail));
    }

    /**
     * 修改库存盘点明细
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeShelfDetail:edit')")
    @Log(title = "库存盘点明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbStoreShelfDetail tbStoreShelfDetail)
    {
        return toAjax(tbStoreShelfDetailService.updateTbStoreShelfDetail(tbStoreShelfDetail));
    }

    /**
     * 删除库存盘点明细
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeShelfDetail:remove')")
    @Log(title = "库存盘点明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbStoreShelfDetailService.deleteTbStoreShelfDetailByIds(ids));
    }
}
